import os
import sys
from PyQt5.QtGui import *
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *

class InputStr(QWidget):
    content_edit_Signal = pyqtSignal(str)
    def __init__(self,label_name):
        super(InputStr, self).__init__()
        self.setMaximumWidth(500)
        self.setWindowTitle('输入')
        self.main_layout = QVBoxLayout()
        self.date_layout = QHBoxLayout()
        self.date_label = QLabel(label_name+':')
        self.content_edit = QLineEdit()
        self.content_edit.setAlignment(Qt.AlignRight | Qt.AlignVCenter)
        self.date_layout.addWidget(self.date_label)
        self.date_layout.addWidget(self.content_edit)

        self.btn_layout = QHBoxLayout()
        self.OK_btn = QPushButton('确定')
        self.OK_btn.setShortcut(Qt.Key_Return)
        self.OK_btn.clicked.connect(self._setContent)
        self.No_btn = QPushButton('取消')
        self.No_btn.clicked.connect(self._closeWindow)
        self.btn_layout.addWidget(self.OK_btn)
        self.btn_layout.addWidget(self.No_btn)

        self.main_layout.addLayout(self.date_layout)
        self.main_layout.addLayout(self.btn_layout)

        self.setLayout(self.main_layout)

    def _setContent(self):
        content = self.content_edit.text()
        self.content_edit_Signal.emit(content)
        # print(content)
        self.close()

    def _closeWindow(self):
        self.close()

if __name__ == '__main__':
    app=QApplication(sys.argv)
    # wt=WageTable()
    # wt.show()
    label_name='目录名称'
    t=InputStr(label_name)
    t.show()
    sys.exit(app.exec_())